<template>
	<view class="sendcar">
		<!-- <u-navbar  title="派单列表"  :background="background" title-color="#FFF" back-icon-color="#fff"></u-navbar> -->
		<view class="public-nav">
			<view class="public-nav-fixed">
				<view class="public-nav-top" style="background-color: #007AFF;color: #FFFFFF;">
					<view class="public-nav-top-status-bar" :style="{ height: systemInfo.statusBarHeight + 'px' }">
					</view>
					<view class="public-nav-top-navbar-inner"
						:style="{ height: navHeight + 'px', lineHeight:navHeight+'px' }">
						<text class="iconfont iconarrow_left-copy" @click="returnclick"></text>
						<view class="" style="display: flex;">
							<view>选择车辆</view>
							
						</view>
						
					</view>
				</view>
			</view>
			<view class="public-nav-placeholder"
				:style="{ height:Number(navHeight)+ Number(systemInfo.statusBarHeight) + 'px' }">
			</view>
		</view>
			<!-- <view class="" @click="xzdataFun">
				新增
			</view> -->
		<view class="xd-main">
			<view class="sendcar-top">
				<view class="sendcar-top-way">
					<button style="margin-left: 0;" type="default" :class="way==1?'buttom-active':''" @click="wayClick(1)">毛重</button>
					<button type="default" :class="way==0?'buttom-active':''" @click="wayClick(0)">净重</button>
				</view>
				
				<!-- <view class="sendcar-top-shaft">
				<button type="default" :class="item.Class" v-for="(item,index) in shaftList" :key="index" @click="shaftClick(item)">{{item.SETTB206CA01}}</button>
			</view> -->
			</view>
			<view class="sendcar-top">
				<view class="sendcar-top-way">
					<u-radio-group v-model="zh" @change="radioGroupChange">
						<u-radio @change="radioChange" v-for="(item, index) in zhlist" :key="index" :name="item.name"
							:disabled="item.disabled">
							{{item.name}}
						</u-radio>
					</u-radio-group>
				</view>
			</view>
			<view class="sendcar-top" v-if="zh=='他人账户'" style="width: 100%; display: block;">
				<view class="sendcar-top-way" @click="zhfun">
					<picker class="addCar-input-one" @change="bindPickerChange" :value="msgobj.wlcj" :range="zhArray"
						range-key="ORMTB510CA00">
						<i class="addCar-phone-placeholder" v-if="msgobj.wlcj<0">请选择账户</i>
						<view v-else class="uni-input">{{zhArray[msgobj.wlcj].ORMTB510CA00}}</view>
					</picker>
				</view>
			</view>
			<view class="sendcar-li" v-for="(item,index) in carList" :key="index">
				<view class="sendcar-li-top" :class="item.classStyle">
					<view class="sendcar-li-top-carnum">
						{{item.ORDTB400CA01}}
					</view>
					<text class="iconfont iconyichu" @click="cardelete(item)"></text>
				</view>
				<view class="sendcar-li-content">
					<view class="sendcar-li-content-number">
						<text class="SLCW-operation" @click="Reduction(item,'small','weight')">-</text>
						<text class="SLCW-ipt" @click="numtap(item,'small','weight')">{{item.ORDTB400CA07}}</text>
						<text class="SLCW-operation" @click="add(item,'small','weight')">+</text>
						<label>
							吨
						</label>
					</view>
					<view class="sendcar-li-content-number">
						<text class="SLCW-operation" @click="Reduction(item,'whole','time')">-</text>
						<text class="SLCW-ipt" @click="numtap(item,'whole','time')">{{item.ORDTB404CA03}}</text>
						<text class="SLCW-operation" @click="add(item,'whole','time')">+</text>
						<label>次</label>
					</view>
				</view>
			</view>
			<view class="sendcar-addcar " @click="carshow=true">
				+添加车辆
			</view>
			<!-- <view class="sendcar-bottom-height">
			</view> -->
		</view>
		<view class="sendcar-bottome-nav">
			<view class="sendcar-bottome-nav-l">
				<view class="sendcar-bottome-nav-l-t" v-if="AuthorizationOBJ.ORMTB417CA06==0">
					￥***
				</view>
				<view class="sendcar-bottome-nav-l-t" v-else>
					￥{{sendTotalMoney}}
				</view>
				<view class="sendcar-bottome-nav-l-b">
					<text>共{{sendTotalCheshu}}车</text> {{sendTotalWeight}}{{materInfo.settb109CA05||'吨'}}
				</view>
			</view>
			<view class="sendcar-bottome-nav-r">
				<button type="default" @click="carUnfinished">申请派单</button>
			</view>
		</view>
		<u-popup v-model="carshow" length="100%" mode="right" @close="carclose">
			<view class="iscar-nav">
				<view class="iscar-nav-top" v-if="platform==false"></view>
				<view v-else :style="{ height: systemInfo.statusBarHeight + 'px' }"></view>
				<view class="iscar-nav-search">
					<view class="iscar-nav-search-btn" @click="carshow=false">
						返回
					</view>
					<view class="iscar-nav-search-ipt">
						<u-search @custom="carcustom" placeholder="请输入车牌号" @change="valChange" v-model="carSearch"
							:show-action="true" action-text="添加" :action-style="actionStyle"></u-search>
					</view>
				</view>
				<view class="iscar-nav-btn">
					<view @click="checkedAll" v-if="ischeckedAll==true">全选</view>
					<view @click="nocheckedAll" v-if="ischeckedAll==false">全不选</view>
					<view @click="determine">确定</view>
				</view>
			</view>
			<view class="iscar-content" :style="platform==false?'padding-top: 24vh;':'padding-top: 14vh'">
				<view v-if="platform==true" :style="{ height: systemInfo.statusBarHeight + 'px' }"></view>
				<u-checkbox-group :wrap="true" @change="checkboxGroupChange">
					<u-checkbox size='40' label-size="38" v-model="item.checked" v-for="(item, index) in carnumlist"
						:key="index" :name="item.name">{{item.name}}</u-checkbox>
				</u-checkbox-group>
			</view>
		</u-popup>
		<u-keyboard ref="uKeyboard" :mask='false' mode="number" v-model="numkeyshow" @change="numkeychange"
			@backspace="numkeybackspace"></u-keyboard>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		Decimal
	} from '../../../static/api/decimal.min.js'
	export default {
		data() {
			return {
				numkeyshow: false,
				carshow: true,
				background: {
					backgroundColor: '#00a1f1',
				},
				actionStyle: {
					backgroundColor: '#00a1f1',
					color: '#FFF',
					width: '100rpx',
					height: '60rpx',
					lineHeight: '60rpx',
					borderRadius: '15rpx',
					margin: '0 20rpx',
				},
				way: 1,
				userinfo: JSON.parse(uni.getStorageSync('userinfo')),
				erpInfo: JSON.parse(uni.getStorageSync('erpinfo')),
				materInfo: JSON.parse(uni.getStorageSync('materInfo')),
				shaftList: '',
				shaftInfo: '',
				carnumlist: [],
				carnumlistinit: [],
				carList: [],
				carSearch: '',
				tapClickItem: {},
				AuthorizationOBJ: '',
				shoppingCartShow: false,
				navId: '',
				ischeckedAll: true,
				systemInfo: '',
				navHeight: '',
				Erptype: '',
				tareMo: 15,
				zhValue: '',
				zhlist: [{
						name: '本账户',
						disabled: false
					},
					{
						name: '他人账户',
						disabled: false
					}
				],
				zh: '本账户',
				typeshow: false,
				infoType: '',
				typeIndex: [0],
				msgobj: {
					wllx: -1,
					wlcj: -1,
					wlcjName: '',
					wlcjId: '',
					wlcjdId: '',
					wllxName: '',
					wllxId: '',
					wllxDj: '',
					kd: '',
					cs: '',
					yf: '',
					cssj: '',
					fdyf: ''
				},
				zhArray: [],
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中

				// djTimes:'',
				platform: uni.getStorageSync('platform'),
			}
		},
		onLoad(option) {
			if (this.userinfo.sign == 'CUS-3') {
				this.queryAuthorization()
			}
			if (uni.getStorageSync('Erptype')) {
				this.Erptype = JSON.parse(uni.getStorageSync('Erptype'))
			}
			this.systemInfo = uni.getSystemInfoSync()
			this.navHeight = this.systemInfo.platform == 'ios' ? 44 : 48;
		},
		onShow() {
			uni.removeStorageSync('sendobj')
			uni.removeStorageSync('obj')
			this.valChange()
			// this.DJtimesFun()
		},
		computed: {
			sendTotalWeight() {
				if (this.carList.length == 0) return 0
				var weight = 0
				this.carList.forEach(item => {
					var a = new Decimal(item.ORDTB400CA07).mul(new Decimal(item.ORDTB404CA03))
					weight = new Decimal(weight).add(new Decimal(a))
				})
				weight = Number(weight.toString().match(/^\d+(?:\.\d{0,2})?/));
				return weight
			},
			sendTotalCheshu() {
				if (this.carList.length == 0) return 0
				var Cheshu = 0
				this.carList.forEach(item => {
					Cheshu = new Decimal(Cheshu).add(new Decimal(item.ORDTB404CA03))
				})
				Cheshu = Number(Cheshu.toString().match(/^\d+(?:\.\d{0,2})?/));
				return Cheshu
			},
			sendTotalMoney() {
				if (this.carList.length == 0) return 0
				var money = 0
				this.carList.forEach(item => {
					console.log(item)
					var a = new Decimal(item.money).mul(new Decimal(item.ORDTB404CA03))
					console.log('a' + a)
					// if(a<1500){
					// 	a=1500
					// }
					money = new Decimal(money).add(new Decimal(a))
				})
				money = Number(money.toString().match(/^\d+(?:\.\d{0,2})?/));
				// money = Number(money.toFixed(2));
				return money
			},
		},
		watch: {
			numkeyshow: function(newQuestion, oldQuestion) {
				if (newQuestion == false) {
					this.carList.forEach(item => {
						item.ORDTB404CA03 = parseInt(item.ORDTB404CA03)
						if (item.ORDTB404CA03 == 0) {
							item.ORDTB404CA03 = 1
						}
					})
				}
			}
		},
		methods: {

			// DJtimesFun(){
			// 	uni.showLoading({
			// 		title: '请求中...',
			// 		mask: true
			// 	});
			// 	if (this.userinfo.sign == 'CUS-1') {
			// 		var ID = this.userinfo.ORMTB400ID
			// 	} else if (this.userinfo.sign == 'CUS-2' || this.userinfo.sign == 'CUS-3') {
			// 		var ID = this.userinfo.ORMTB410ID
			// 	}
			// 	uni.request({
			// 		url: this.baseUrl + '/orm/ormtb440/selectMP',
			// 		method: 'POST',
			// 		dataType: 'json',
			// 		data: {
			// 			ORMTB410ID: ID,
			// 		},
			// 		success: (res) => {
			// 			console.log(res);
			// 			if (res.data.code == 200) {
			// 				var data = res.data.data
			// 				console.log(data)
			// 				this.djTimes = data

			// 			} else {

			// 			}
			// 			uni.hideLoading();
			// 		},
			// 		fail: (res) => {
			// 			uni.hideLoading();
			// 			this.$refs.uToast.show({
			// 				title: res.errMsg,
			// 				type: 'default',
			// 				icon: false
			// 			})
			// 		}
			// 	});
			// },

			returnclick() {
				if (this.Erptype == 3) {
					uni.reLaunch({
						url: '/pages/priceComparison/index'
					})
				} else {
					uni.reLaunch({
						url: '/pages/SOMater/index'
					})
				}
			},
			zhfun() {
				this.typeshow = true
				this.zhdataFun()

			},
			radioChange(e) {
				console.log(e);
			},
			radioGroupChange(e) {
				console.log(e);
			},
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.detail.value)
				this.msgobj.wlcj = e.detail.value
				console.log(typeof this.msgobj.wlcj)
				this.msgobj.wlcjName = this.zhArray[this.msgobj.wlcj].ORMTB510CA00
				this.msgobj.wlcjId = this.zhArray[this.msgobj.wlcj].ORMTB510ID

				// this.queryGwcList()
				// this.msgobj.wllx = -1
			},
			xzdataFun(){
				
			},
			zhdataFun() {
				uni.showLoading({
					title: '请求中...',
					mask: true
				});
				if (this.userinfo.sign == 'CUS-1') {
					var ID = this.userinfo.ORMTB400ID
				} else if (this.userinfo.sign == 'CUS-2' || this.userinfo.sign == 'CUS-3') {
					var ID = this.userinfo.ORMTB410ID
				}
				uni.request({
					url: this.baseUrl + '/orm/ormtb440/selectOrmtb510',
					method: 'POST',
					dataType: 'json',
					data: {
						ORMTB410ID: ID,
					},
					success: (res) => {
						console.log(res);
						if (res.data.code == 200) {
							var data = res.data.data
							this.zhArray = data
							// this.carnumlist = []
							// data.forEach(item => {
							// 	this.carnumlist.push({
							// 		checked: false,
							// 		name: item.SETTB402CA00,
							// 		tareMo: item.ORMTB440PZ,
							// 		disabled: false,
							// 	})
							// })
						} else {

						}
						uni.hideLoading();
					},
					fail: (res) => {
						uni.hideLoading();
						this.$refs.uToast.show({
							title: res.errMsg,
							type: 'default',
							icon: false
						})
					}
				});
			},
			typeOnConfirm(e) {
				this.typeIndex = [(this.typeList || []).findIndex((profile) => profile.value === e[0].value)]
				this.infoType = e[0].value
				this.rechargeType = e[0].label
				this.typeshow = false;
			},
			queryAuthorization() { //查询子账户权限
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				uni.request({
					url: this.baseUrl + '/orm/ormtb417/selectAccess/' + this.userinfo.ORMTB417ID,
					method: 'GET',
					success: (res) => {
						console.log(res);
						uni.hideLoading();
						if (res.data.code == 200) {
							this.AuthorizationOBJ = res.data.data
						} else {
							this.$refs.uToast.show({
								title: res.data.message,
								type: 'default',
								icon: false
							})
						}
					},
					fail: (res) => {
						uni.hideLoading();
						this.$refs.uToast.show({
							title: res.errMsg,
							type: 'default',
							icon: false
						})
					}
				});
			},
			QueryShaft() { //获取轴数
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				uni.request({
					url: this.baseUrl + '/order/v1/order105/888888',
					method: 'GET',
					success: (res) => {
						console.log(res);
						uni.hideLoading();
						if (res.data.result == 1) {
							this.shaftList = res.data.data || []
							for (var i = 0; i < this.shaftList.length; i++) {
								if (i == 0) {
									this.shaftList[i].Class = 'buttom-active'
									this.shaftInfo = this.shaftList[i]
								} else {
									this.shaftList[i].Class = ''
								}
							}
						} else {
							this.$refs.uToast.show({
								title: res.data.message,
								type: 'default',
								icon: false
							})
						}
					},
					fail: (res) => {
						uni.hideLoading();
						this.$refs.uToast.show({
							title: res.errMsg,
							type: 'default',
							icon: false
						})
					}
				});
			},
			wayClick(type) {
				this.way = type
				this.carList.forEach(item => {
					item.money = this.carmoney(item.ORDTB400CA07, item.tareMo)
					item.initCarmoney = this.initCarmoney(item.ORDTB400CA07, item.tareMo)
				})
			},
			shaftClick(e) {
				this.shaftInfo = e
				this.shaftList.forEach(item => {
					if (e.SETTB206CA00 == item.SETTB206CA00) {
						item.Class = 'buttom-active'
					} else {
						item.Class = ''
					}
				})
				this.carList.forEach(item => {
					item.ORDTB400CA07 = this.shaftInfo.SETTB206CA03 * 1
					item.money = this.carmoney(item.ORDTB400CA07, item.tareMo)
					item.initCarmoney = this.initCarmoney(item.ORDTB400CA07, item.tareMo)
				})
			},
			carcustom() {
				this.carSearch = ''
				uni.navigateTo({
					url: '/pages/vehicleAddCar/index'
				})
				// return
				// var express =
				// 	/^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领])|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][0-9]{2}([0-9]|[A-Z]){5}))$/;
				// if (express.test(this.carSearch)) {
				// 	if (this.carnumlist.length > 0) {
				// 		uni.showToast({
				// 			title: '该车辆已绑定',
				// 			duration: 5000,
				// 			icon: 'none',
				// 		});
				// 		return
				// 	} else {
				// 		uni.showLoading({
				// 			title: '请求中...',
				// 			mask: true
				// 		});
				// 		if (this.userinfo.sign == 'CUS-1') {
				// 			var ID = this.userinfo.ORMTB400ID
				// 		} else if (this.userinfo.sign == 'CUS-2' || this.userinfo.sign == 'CUS-3') {
				// 			var ID = this.userinfo.ORMTB410ID
				// 		}
				// 		uni.request({
				// 			url: this.baseUrl + '/set/settb402/insert',
				// 			method: 'POST',
				// 			dataType: 'json',
				// 			data: {
				// 				SETTB402CA00: this.carSearch,
				// 				personID: ID,
				// 				sign: this.userinfo.sign
				// 			},
				// 			success: (res) => {
				// 				console.log(res);
				// 				if (res.data.code == 200) {
				// 					this.valChange()
				// 					this.carSearch = ''
				// 				} else {
				// 					this.$refs.uToast.show({
				// 						title: res.data.message,
				// 						type: 'default',
				// 						icon: false
				// 					})
				// 				}
				// 				uni.hideLoading();
				// 			},
				// 			fail: (res) => {
				// 				uni.hideLoading();
				// 				this.$refs.uToast.show({
				// 					title: res.errMsg,
				// 					type: 'default',
				// 					icon: false
				// 				})
				// 			}
				// 		});
				// 	}
				// 	this.carNumbers = this.settb119.name
				// } else {
				// 	mui.toast('')
				// 	uni.showToast({
				// 		title: '请输入有效的车牌号信息',
				// 		duration: 5000,
				// 		icon: 'none',
				// 	});
				// }
			},
			valChange() { //输入input发生变化
				this.carnumlist = []
				this.carSearch = this.carSearch.toUpperCase()
				uni.showLoading({
					title: '请求中...',
					mask: true
				});
				if (this.userinfo.sign == 'CUS-1') {
					var ID = this.userinfo.ORMTB400ID
				} else if (this.userinfo.sign == 'CUS-2' || this.userinfo.sign == 'CUS-3') {
					var ID = this.userinfo.ORMTB410ID
				}
				uni.request({
					url: this.baseUrl + '/set/settb402/selectSettb402BySign',
					method: 'POST',
					dataType: 'json',
					data: {
						sign: this.userinfo.sign,
						SETTB402CA00: this.carSearch,
						ID: ID,
					},
					success: (res) => {
						console.log(res);
						if (res.data.code == 200) {
							var data = res.data.data
							this.carnumlist = []
							data.forEach(item => {
								this.carnumlist.push({
									checked: false,
									name: item.SETTB402CA00,
									tareMo: item.ORMTB440PZ,
									disabled: false,
								})
							})
						} else {

						}
						uni.hideLoading();
					},
					fail: (res) => {
						uni.hideLoading();
						this.$refs.uToast.show({
							title: res.errMsg,
							type: 'default',
							icon: false
						})
					}
				});

			},
			carclose() {
				this.carSearch = ''
			},
			checkboxGroupChange() {
				var arr = []
				this.carnumlist.map(val => {
					if (val.checked == true) {
						arr.push(arr)
					}
				})
				if (arr.lenth == this.carnumlist.length) {
					this.ischeckedAll = false
				} else {
					this.ischeckedAll = true
				}
			},
			determine() {
				this.carnumlist.forEach(item => {
					if (item.checked == true) {
						var i = (this.carList || []).findIndex((profile) => profile.ORDTB400CA01 === item.name);
						if (i == '-1') {
							var money = this.carmoney(50, item.tareMo)
							var initCarmoney = this.initCarmoney(50, item.tareMo)
							console.log(item.name)
							var carObj = {
								ORDTB400CA01: item.name, //车牌号
								ORDTB400CA07: 50, //申请重量
								ORDTB404CA03: 1, //申请车次
								tareMo: item.tareMo, //皮重
								money: money,
								initCarmoney: initCarmoney
							}
							this.carList.push(carObj)
						}
					}
				})
				this.carshow = false
			},
			checkedAll() {
				this.carnumlist.map(val => {
					val.checked = true
				})
				this.ischeckedAll = false
			},
			nocheckedAll() {
				this.carnumlist.map(val => {
					val.checked = false
				})
				this.ischeckedAll = true
			},
			carUnfinished(type) { //校验车辆是否有未完成的订单
				if (this.carList.length == 0) {
					uni.showToast({
						title: '请选择车辆',
						duration: 5000,
						icon: 'none',
					});
					return
				}
				this.sumbSendOrders()

			},
			sumbSendOrders() {
				var ORMTB400ID = ''
				var ORMTB400CA00 = ''
				var ORMTB410ID = ''
				var ORMTB410CA00 = ''
				var ORMTB440CA26 = ''
				var ORMTB440CA27 = ''
				if (this.userinfo.sign == 'CUS-1') {
					ORMTB400ID = this.userinfo.ORMTB400ID
					ORMTB400CA00 = this.userinfo.ORMTB400CA00
				} else if (this.userinfo.sign == 'CUS-2') {
					ORMTB410ID = this.userinfo.ORMTB410ID
					ORMTB410CA00 = this.userinfo.ORMTB410CA00
					ORMTB400ID = this.userinfo.ORMTB400ID
					// ORMTB410CA01=this.userinfo.ORMTB410CA01
				} else if (this.userinfo.sign == 'CUS-3') {
					ORMTB440CA26 = this.userinfo.ORMTB417ID
					ORMTB440CA27 = this.userinfo.PERTB005CA02
					ORMTB410CA00 = this.userinfo.ORMTB410CA00
					ORMTB400ID = this.userinfo.ORMTB400ID
					ORMTB410ID = this.userinfo.ORMTB410ID
				}
				var sendobj = {
					ORMTB400CA03: this.userinfo.ORMTB400CA03, //大客户代码
					ORMTB400CA00: ORMTB400CA00, //一级派单必传
					// ORMTB400CA00:ORMTB400ID,//一级派单必传
					sign: this.userinfo.sign, //CUS-1一级客户   CUS-2 二级客户
					ORMTB410ID: ORMTB410ID, //二级客户ID（二级派单必传）
					ORMTB410CA00: ORMTB410CA00, //二级客户名称（二级派单必传）
					// ORMTB410CA00:ORMTB410CA01,//二级客户名称（二级派单必传）
					ORMTB400ID: ORMTB400ID, //二级客户名称（二级派单必传）
					ORDTB400CA08: '', //派单物料金额
					ORMTB440CA08: this.materInfo.settb109CA01, //派单物料单价
					ORMTB440CF00: '', //派单类型ZG直供LS零售QD抢单
					ORMTB440CA17: this.userinfo.PERTB005ID, //登录用户ID
					ORMTB440CA18: this.userinfo.PERTB005CA02, //登录用户名称
					ORMTB440CA21: '',
					ORMTB440CA12: '', //派单运费
					ORMTB440CA13: '', //配送地ID
					ORMTB440CA14: '', //配送地名称
					ORMTB440CA15: '', //工地ID
					ORMTB440CA16: '', //工地名称
					SETTB400CA02: '', //优惠方式
					SETTB400CA06: '', //客户等级优惠
					ORMTB440CA23: this.erpInfo.SETTB100ID, //一级企业ID
					ORMTB440CA24: this.erpInfo.SETTB99CA00, //一级企业名称
					ORDTB400CA04: this.materInfo.settb109ID, //物料ID
					ORMTB440CA07: this.materInfo.settb109CA00, //物料名称
					ORDTB400CA09: this.erpInfo.SETTB99ID, //二级企业代码
					ORMTB440CA05: this.erpInfo.SETTB99CA00, //二级名称
					ORMTB440CA26: ORMTB440CA26, //子账号id
					ORMTB440CA27: ORMTB440CA27, //子账号名称
					SETTB109CB09: this.materInfo.settb109CB09, //是否开启副账号扣款，0不开启，1开启
					ORDTB400CA06: this.way, //派单方式（0净重，1毛重）
					carList: this.carList
				}
				var str = JSON.stringify(sendobj)
				uni.setStorageSync('sendobj', str);
				uni.navigateTo({
					url: '/pages/SOsubmit/index'
				})
			},
			cardelete(item) {
				var i = (this.carList || []).findIndex((profile) => profile.ORDTB400CA01 === item.ORDTB400CA01);
				this.carList.splice(i, 1)
				var j = (this.carnumlist || []).findIndex((profile) => profile.name === item.ORDTB400CA01);
				this.carnumlist[j].checked = false
			},
			Reduction(item, numtype, type) {
				var i = (this.carList || []).findIndex((profile) => profile.ORDTB400CA01 === item.ORDTB400CA01);
				if (type == 'weight') {
					if (this.carList[i].ORDTB400CA07 == 0) return
					this.carList[i].ORDTB400CA07 = new Decimal(this.carList[i].ORDTB400CA07).sub(new Decimal(1))
					this.carList[i].ORDTB400CA07 = Number(this.carList[i].ORDTB400CA07.toString().match(
						/^\d+(?:\.\d{0,2})?/));
					this.carList[i].money = this.carmoney(this.carList[i].ORDTB400CA07, this.carList[i].tareMo)
					this.carList[i].initCarmoney = this.initCarmoney(this.carList[i].ORDTB400CA07, this.carList[i].tareMo)
				} else {
					if (this.carList[i].ORDTB404CA03 == 1) return
					this.carList[i].ORDTB404CA03 = new Decimal(this.carList[i].ORDTB404CA03).sub(new Decimal(1))
					this.carList[i].ORDTB404CA03 = Number(this.carList[i].ORDTB404CA03.toString().match(
						/^\d+(?:\.\d{0,2})?/));
				}
			},
			add(item, numtype, type) {
				var i = (this.carList || []).findIndex((profile) => profile.ORDTB400CA01 === item.ORDTB400CA01);
				if (type == 'weight') {
					this.carList[i].ORDTB400CA07 = new Decimal(this.carList[i].ORDTB400CA07).add(new Decimal(1))
					this.carList[i].money = this.carmoney(this.carList[i].ORDTB400CA07, this.carList[i].tareMo)
					this.carList[i].initCarmoney = this.initCarmoney(this.carList[i].ORDTB400CA07, this.carList[i].tareMo)
					this.carList[i].ORDTB400CA07 = Number(this.carList[i].ORDTB400CA07.toString().match(
						/^\d+(?:\.\d{0,2})?/));
				} else {
					this.carList[i].ORDTB404CA03 = new Decimal(this.carList[i].ORDTB404CA03).add(new Decimal(1))
					this.carList[i].ORDTB404CA03 = Number(this.carList[i].ORDTB404CA03.toString().match(
						/^\d+(?:\.\d{0,2})?/));
					if (this.carList[i].ORDTB404CA03 > 9999) return this.carList[i].ORDTB404CA03 = 9999
				}
			},
			numtap(item, numtype, type) {
				this.numkeyshow = true
				this.tapClickItem.item = item
				this.tapClickItem.numtype = numtype
				this.tapClickItem.type = type
			},
			numkeychange(e) {
				var j = (this.carList || []).findIndex((profile) => profile.ORDTB400CA01 === this.tapClickItem.item
					.ORDTB400CA01);
				if (this.tapClickItem.numtype == "whole") {
					if (e == '.') return
					if (this.tapClickItem.type == 'time') {
						if (this.carList[j].ORDTB404CA03 == '' && e == 0) return
						this.carList[j].ORDTB404CA03 = this.carList[j].ORDTB404CA03 + '' + e
						if (this.carList[j].ORDTB404CA03.indexOf(".") < 0 && num !=
							"") { //以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
							this.carList[j].ORDTB404CA03 = parseFloat(this.carList[j].ORDTB404CA03)
						}
						if (this.carList[j].ORDTB404CA03 > 9999) return this.carList[j].ORDTB404CA03 = 9999
					}
				} else {
					if (this.tapClickItem.type == 'weight') {
						var num = String(this.carList[j].ORDTB400CA07)
						num = num + e
						num = num.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
						num = num.replace(/^\./g, "1"); //验证第一个字符是数字
						num = num.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
						num = num.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
						num = num.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
						if (num.indexOf(".") < 0 && num != "") { //以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
							num = parseFloat(num)
						}
						num = String(num)
						if (num.indexOf(".") > 0) {
							var arr = num.split('.')
							if (arr[1].length > 1) {
								num = Number(num.toString().match(/^\d+(?:\.\d{0,2})?/));
							}
						}
						this.carList[j].money = this.carmoney(num, this.carList[j].tareMo)
						this.carList[j].initCarmoney = this.initCarmoney(num, this.carList[j].tareMo)
						this.carList[j].ORDTB400CA07 = 1
						this.$nextTick(function() {
							this.carList[j].ORDTB400CA07 = num
						})
					}
				}
			},
			numkeybackspace() {
				var j = (this.carList || []).findIndex((profile) => profile.ORDTB400CA01 === this.tapClickItem.item
					.ORDTB400CA01);
				var num
				if (this.tapClickItem.type == "weight") {
					num = String(this.carList[j].ORDTB400CA07)
					this.carList[j].ORDTB400CA07 = num.substr(0, num.length - 1)
					if (this.carList[j].ORDTB400CA07 == '') {
						this.carList[j].ORDTB400CA07 = 0
						this.carList[j].money = this.carmoney(this.carList[j].ORDTB400CA07, this.carList[j].tareMo)
						this.carList[j].initCarmoney = this.initCarmoney(this.carList[j].ORDTB400CA07, this.carList[j]
							.tareMo)
						return
					}
					this.carList[j].money = this.carmoney(this.carList[j].ORDTB400CA07, this.carList[j].tareMo)
					this.carList[j].initCarmoney = this.initCarmoney(this.carList[j].ORDTB400CA07, this.carList[j].tareMo)
				} else {
					num = String(this.carList[j].ORDTB404CA03)
					this.carList[j].ORDTB404CA03 = num.substr(0, num.length - 1)
					if (this.carList[j].ORDTB404CA03 == '') return this.carList[j].ORDTB404CA03 = 0
				}
			},
			carmoney(weight, tareMo) {
				if (this.way == 1) {
					var Jweigth = new Decimal(weight).sub(new Decimal(tareMo))
					// if (Jweigth < 20) {
					// 	Jweigth = 20
					// }
					var money = new Decimal(Jweigth).mul(new Decimal(this.materInfo.settb109CA01))

				} else {
					var money = new Decimal(weight).mul(new Decimal(this.materInfo.settb109CA01))
				}

				money = Number(money.toString().match(/^\d+(?:\.\d{0,2})?/));
				money = Number(money.toFixed(2));
				console.log(money)
				return money
			},
			initCarmoney(weight, tareMo) {
				if (this.way == 1) {
					var Jweigth = new Decimal(weight).sub(new Decimal(tareMo))
					// if (Jweigth < 20) {
					// 	Jweigth = 20
					// }
					var money = new Decimal(Jweigth).mul(new Decimal(this.materInfo.settb109CA01_ys))
				} else {
					var money = new Decimal(weight).mul(new Decimal(this.materInfo.settb109CA01_ys))
				}
				console.log(money)
				money = Number(money.toString().match(/^\d+(?:\.\d{0,2})?/));
				console.log(money)
				return money
			},
		}
	}
</script>

<style scoped>
	.sendcar {
		width: 100vw;
		min-height: 100vh;
		background-color: #e3e3e3;
	}

	.sendcar-top {
		display: flex;
		border-bottom: 2rpx solid #e3e3e3;
		padding-bottom: 10rpx;
		padding-top: 10rpx;
		/* background-color: #fff; */
	}

	.sendcar-top-way {
		margin-left: 40rpx;
	}

	.sendcar-top-way button {
		display: inline-block;
		height: 50rpx;
		width: 100rpx;
		line-height: 50rpx;
		font-size: 38rpx;
		border: none;
		background-color: #e3e3e3;
		color: #fff;
		padding: 0;
		margin-top: 40rpx;
		margin-left: 30rpx;
	}

	.sendcar-top-way .buttom-active {
		background-color: #02a2f4;
	}

	.sendcar-top-shaft {
		flex: 1;
	}

	.sendcar-top-shaft button {
		display: inline-block;
		height: 40rpx;
		width: 70rpx;
		line-height: 40rpx;
		font-size: 24rpx;
		border: 1rpx solid #e3e3e3;
		background-color: #fff;
		color: #666;
		padding: 0;
		margin-top: 45rpx;
		margin-left: 40rpx;
	}

	.sendcar-top-shaft .buttom-active {
		border: 2rpx solid #02a2f4;
		color: #02a2f4;
	}

	.sendcar-top-shaft button+button {
		margin-left: 20rpx;
	}

	.sendcar-li {
		padding: 30rpx 20rpx;
		background-color: #fff;
	}

	.sendcar-li-top {
		display: flex;
		justify-content: space-between;
		color: #333;
		font-size: 40rpx;
		font-weight: 600;
	}

	.sendcar-li-top-active {
		background-color: rgba(255, 88, 88, .6);
	}

	.sendcar-li-top .iconyichu {
		color: #999;
		margin-right: 30rpx;
		font-size: 36rpx;
	}

	.sendcar-li-content {
		display: flex;
		justify-content: space-between;
		margin-top: 30rpx;
	}

	.SLCW-operation {
		display: inline-block;
		width: 40rpx;
		height: 40rpx;
		line-height: 40rpx;
		border-radius: 50%;
		font-size: 36rpx;
		background-color: #999;
		color: #fff;
		text-align: center;
		vertical-align: middle;
	}

	.SLCW-ipt {
		display: inline-block;
		width: 130rpx;
		height: 60rpx;
		line-height: 60rpx;
		text-align: center;
		font-size: 26rpx;
		border: 2rpx solid rgba(0, 212, 254, .7);
		border-radius: 5rpx;
		margin: 0 15rpx;
		overflow: hidden;
		vertical-align: middle;
	}

	.sendcar-li-content-number label {
		margin-left: 10rpx;
	}

	.iscar-nav {
		position: fixed;
		top: 0;
		width: 100%;
		/* height: 22vh; */
		/* box-sizing: border-box; */
		z-index: 2;
		background-color: #FFF;
	}

	.iscar-content {
		/* margin-top: 24vh; */
	}

	.iscar-nav-top {
		height: 10vh;
		/* background-color: #e3e3e3; */
	}

	.iscar-nav-search {
		display: flex;
		/* background-color: #e3e3e3; */
		padding-bottom: 20rpx;
	}

	.iscar-nav-search-ipt {
		flex: 1;
	}

	.iscar-nav-search-btn {
		width: 100rpx;
		height: 60rpx;
		line-height: 60rpx;
		font-size: 28rpx;
		text-align: center;
		color: #333;
		margin: 0 20rpx;
	}

	.iscar-nav-btn {
		display: flex;
		justify-content: space-between;
		height: 90rpx;
		line-height: 90rpx;
		font-size: 36rpx;
		color: #333;
		padding: 0 40rpx;
		border-top: 2rpx solid #e3e3e3;
		border-bottom: 2rpx solid #e3e3e3;
		background-color: #fff;
	}

	.iscar-nav-btn view+view {
		color: #02a2f4;
	}

	.iscar-nav-btn view {
		/* width: 100rpx; */
		text-align: center;
	}

	.iscar-content {
		padding-left: 30rpx;
	}

	.sendcar-addcar {
		padding: 20rpx 40rpx;
		color: #02a2f4;
		font-size: 38rpx;
		/* background-color: #fff; */
	}

	.sendcar-bottom-height {
		height: 120rpx;
	}

	.sendcar-bottome-nav {
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		display: flex;
		height: 120rpx;
		overflow: hidden;
		box-sizing: border-box;
		z-index: 2;
		background-color: #fff;
	}

	.sendcar-bottome-nav-l {
		flex: 1;
		text-align: right;
		padding-right: 20rpx;
		margin-top: 20rpx;
	}

	.sendcar-bottome-nav-l-t {
		height: 40rpx;
		font-size: 34rpx;
		color: #333;
		overflow: hidden;
	}

	.sendcar-bottome-nav-l-b {
		height: 40rpx;
		overflow: hidden;
		font-size: 24rpx;
		color: #999;
	}

	.sendcar-bottome-nav-l-b text {
		margin-right: 10rpx;
	}

	.sendcar-bottome-nav-r>button {
		display: inline-block;
		height: 120rpx;
		line-height: 120rpx;
		color: #FFF;
		background-color: #02a2f4;
		/* background-color: #e5c000; */
		font-size: 32rpx;
	}

	.sendcar-bottome-nav-r>button+button {
		background-color: #02a2f4;
		margin-left: 5rpx;
	}

	.xd-main {
		/* margin-bottom: 20rpx; */
		background-color: #FFF;
		border-radius: 20rpx;
		margin-left: 10rpx;
		margin-right: 10rpx;
		margin-top: 10rpx;
	}
</style>
